Skip to content

fix(clickhouse): tolerate the decimal reader's exponent parse errors - #36

Open
groeneai wants to merge 1 commit into
ClickHouse:mainfrom
groeneai:fix-clickhouse-decimal-exponent-parse-error
Open

groeneai wants to merge 1 commit into
ClickHouse:mainfrom
groeneai:fix-clickhouse-decimal-exponent-parse-error

Conversation

@groeneai

Copy link
Copy Markdown

The 2026-11-28 master nightly (SQLancer (arm_release), reproducer) reported this from CODDTest:

java.sql.SQLException: Code: 72. DB::Exception: Cannot parse exponent while reading decimal: while converting 'e-y*ZLG' to Decimal(5, 2): In scope SELECT toTypeName((((CAST('-702', 'Decimal(5, 2)')) != ('e-y*ZLG')) OR (NOT (-1970998926)))) AS t, ... (CANNOT_PARSE_NUMBER)
	at sqlancer.clickhouse.transport.ClickHouseClientV2Transport.asSqlException(ClickHouseClientV2Transport.java:131)
	at sqlancer.clickhouse.transport.ClickHouseTransportStatement.executeQuery(ClickHouseTransportStatement.java:46)
	at sqlancer.clickhouse.oracle.coddtest.ClickHouseCODDTestOracle.evaluateSingleRow(ClickHouseCODDTestOracle.java:302)
	at sqlancer.clickhouse.oracle.coddtest.ClickHouseCODDTestOracle.buildConstantPhi(ClickHouseCODDTestOracle.java:91)

Comparing a decimal with a random string makes the server convert the string to the decimal type, and an error is the right answer for 'e-y*ZLG'. A string that starts with e/E enters the decimal reader's exponent branch, which throws CANNOT_PARSE_NUMBER (Cannot parse exponent while reading decimal, or Exponent is out of range while reading decimal when the exponent overflows), and convertFieldToType passes it through instead of rewriting it to Cannot convert string as it does for 'abc'. ClickHouseErrors already lists the integer and float readers' wordings for this shape (Cannot parse number without any digits, Cannot read floating point value, ...) but not these two, so the raw SQLException became a finding.

This adds both wordings to getExpectedExpressionErrors().

Checked against master 26.12.1.1 (debug build, .claude/clickhouse-config/ overrides):

check before with this PR
errorIsExpected(<CI message>), and the same for the out-of-range message (SELECT CAST(1 AS Decimal(5, 2)) <> '.01e-2147483647') false, false true, true
CODDTest, 4 threads, 5 min, local-only patch prefixing 1 in 4 Randomly.getString() results with e- 7 findings, all this signature none (85,267 queries)
CODDTest, unbiased, 10 threads, 10 min 1 finding, this signature ('e' vs Decimal(13, 3)) none (365,493 queries)

mvn verify -DskipTests=true -Djacoco.skip=true passes with 0 Checkstyle violations.

Related: ClickHouse/ClickHouse#128538

🤖 Generated with Claude Code

Comparing a decimal with a random string literal makes the server convert
the string to the decimal type. A string starting with e/E enters the
decimal reader's exponent branch, which throws CANNOT_PARSE_NUMBER
("Cannot parse exponent while reading decimal", or "Exponent is out of
range while reading decimal" when the exponent overflows Int32), and
convertFieldToType passes it through instead of rewriting it to
TYPE_MISMATCH "Cannot convert string". The integer and float readers'
wordings for the same shape are already expected; these two were not, so
CODDTest reported the raw SQLException (NightlySQLancer, SQLancer
(arm_release), master 9c5336e66e25, 2026-11-28).

Related: ClickHouse/ClickHouse#128538

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant